function TrayManager(trayDiv, me){
  var objs = new Array();
  var template = "trayTemplate";
  this.addItemToTray = function (item){
	item.y = objs.length*150+10;
    var exists = false;
    for (var i=0; i<objs.length; i++){
     if ( objs[i].id== item.id && objs[i].ownerId == item.ownerId){
       exists = true;
     }
    }
    if (!exists){
      objs.push(item);
      repaint();
    }
  } 
  
  this.removeItemFromTray = function ( id, owner){
   var tmp = new Array(); 
   var index = 0;
    for (var i=0; i<objs.length; i++){
      if (objs[i].id != id || objs[i].ownerId!= owner){
        objs[i].y = index++*150+10;
        tmp.push(objs[i]);
      }
    }
    objs = tmp;
    repaint();
  }
  
  function repaint(){ 
    var data = new Object();
    data["items"] = objs;
    var hasMe = false;
    var hasTheOther = true;
    for (var i=0; i<objs.length; i++){
      if (objs[i].ownerId == me){ 
         hasMe = true;
      }
      if (objs[i].ownerId!=me){
        hasTheOther = true;
      }
    }
    if (hasMe && hasTheOther){
    	data["canReq"] = true;
    }else {
       	data["canReq"] = false;
    }
    $(trayDiv).innerHTML = TrimPath.processDOMTemplate(template, data);		  
  }
  
  this.getItemsInTray = function (){
    return objs;
  }
  
  
}
